package com.novax.ex.activity.open.api.inner;

import com.novax.ex.activity.open.model.query.IeoConfigQuery;
import com.novax.ex.activity.open.model.query.OrderDistributionQuery;
import com.novax.ex.activity.open.model.query.OrderInnerQuery;
import com.novax.ex.activity.open.model.request.*;
import com.novax.ex.activity.open.model.response.*;
import com.novax.ex.common.results.ReturnResult;
import com.novax.ex.common.util.PageUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import java.math.BigDecimal;
import java.util.List;

/**
 * summary: IEO后台-活动配置
 *
 * @author shaw
 * @date 11/30/22 11:14
 */
@Tag(name = "IEO后台-活动配置", description = "IEO后台-活动配置")
@FeignClient(url = "${remote.activity-service.endpoint}", name = "IeoInnerConfigApi", contextId = "IeoInnerConfigApi")
@RequestMapping("/v3/private/ieos")
public interface IeoInnerConfigApi {

    @Operation(summary = "后台活动配置分页查询")
    @GetMapping
    ReturnResult<PageUtil<IeoConfigResponse>> page(@ParameterObject @SpringQueryMap IeoConfigQuery ieoConfigQuery);

    @Operation(summary = "后台活动配置新增")
    @PostMapping
    ReturnResult<?> add(@RequestHeader("language") String language, @Valid @RequestBody IeoConfigRequest configRequest, BindingResult bindingResult);

    @Operation(summary = "后台活动配置修改")
    @PutMapping("/{ieoId}")
    ReturnResult<?> modify(@RequestHeader("language") String language, @PathVariable Long ieoId, @RequestBody IeoConfigRequest configRequest);

    //-----

    @Operation(summary = "查询vip配置")
    @GetMapping(value = "/{ieoId}/vips")
    ReturnResult<List<IeoVipLimitResponse>> vipConfigs(@PathVariable Long ieoId);

    @Operation(summary = "修改vip配置")
    @PutMapping(value = "/vips/{vipId}")
    ReturnResult<?> modifyVipConfig(@RequestHeader("language") String language, @PathVariable Long vipId, @Valid @RequestBody IeoVipRequest vipRequest, BindingResult bindingResult);

    //-----

    @Operation(summary = "查询币种配置")
    @GetMapping(value = "/{ieoId}/currencies")
    ReturnResult<List<IeoCurrencyConfigResponse>> currencyConfigs(@PathVariable Long ieoId);

    @Operation(summary = "新增币种配置")
    @PostMapping(value = "/{ieoId}/currencies")
    ReturnResult<?> addCurrencyConfig(@RequestHeader("language") String language, @PathVariable Long ieoId, @Valid @RequestBody IeoCurrencyRequest currencyRequest, BindingResult bindingResult);

    @Operation(summary = "修改币种配置")
    @PutMapping(value = "/currencies/{currencyId}")
    ReturnResult<?> modifyCurrencyConfig(@RequestHeader("language") String language, @PathVariable Long currencyId, @Valid @RequestBody IeoCurrencyRequest currencyRequest, BindingResult bindingResult);

    @Operation(summary = "删除币种配置")
    @DeleteMapping(value = "/currencies/{currencyId}")
    ReturnResult<?> removeCurrencyConfig(@RequestHeader("language") String language, @PathVariable Long currencyId);

    //-----

    @Operation(summary = "查询项目介绍")
    @GetMapping(value = "/{ieoId}/contents")
    ReturnResult<List<IeoContentResponse>> contents(@PathVariable Long ieoId);

    @Operation(summary = "新增项目介绍")
    @PostMapping(value = "/{ieoId}/contents")
    ReturnResult<Void> addContent(@RequestHeader("language") String language,
                               @PathVariable Long ieoId,
                               @Valid @RequestBody IeoContentRequest contentRequest,
                               BindingResult bindingResult);

    @Operation(summary = "修改项目介绍")
    @PutMapping(value = "/contents/{contentId}")
    ReturnResult<Boolean> modifyContent(@RequestHeader("language") String language,
                                  @PathVariable(value = "contentId") Long contentId,
                                  @Valid @RequestBody IeoContentRequest contentRequest,
                                  BindingResult bindingResult);


    @Operation(summary = "真实认购份数")
    @GetMapping(value = "/subscribe/{ieoId}")
    ReturnResult<IeoSubscribeCopyResponse> realSubscribeCopy(@RequestHeader("language") String language,
                                                             @PathVariable Long ieoId);

    @Operation(summary = "用户的申购记录")
    @GetMapping("/orders")
    ReturnResult<PageUtil<IeoSubscribeResponse>> subscribePage(@ParameterObject OrderInnerQuery innerQuery);


    @Operation(summary = "修改认购倍数")
    @PostMapping("/config/{ieoId}")
    ReturnResult<Boolean> modifyMultiple(
            @RequestHeader("language") String language,
            @PathVariable Long ieoId,
            @RequestParam BigDecimal multiple);

}